import { Pipe, PipeTransform } from '@angular/core';

@Pipe({// 用来转换通知状态
  name: 'getSendType'
})
export class GetSendTypePipe implements PipeTransform {

  transform(value: string): string {
    let map = {
        TRADE_ORDER: '支付',
        WITHDRAWAL: '转出',
        DEPOSIT: '转入',
        WITHDRAWAL_CASH: '提现'
    };
    return map[value];
  }
}

@Pipe({// 用来显示余额
  name: 'isShowCoin'
})
export class IsShowCoin implements PipeTransform {

  transform(value: string): string {
    const text = value ? '隐藏' : '显示';
    return text;
  }
}

@Pipe({// 用来计算手续费
  name: 'getCommission'
})
export class GetCommission implements PipeTransform {

  transform(value: number, coin: any): string {
    let text ;
   if (value){
    let fee = 0;
    if ((value * coin.merchantWithdrawalCashFeePercent) < coin.merchantWithdrawalCashFeePercent) {
      fee = 0.02;
    } else {
      fee = value * coin.merchantWithdrawalCashFeePercent;
    }
    text = fee;
   } else {
    text = 0;
   }
    return text;
  }
}

@Pipe({// 列表内狀態的翻譯
  name: 'getListKeyType'
})
export class GetListKeyType implements PipeTransform {

  transform(value: string): string {
    let text = value;
    let map = {
      SCAN_PAY : '扫码支付',
      AUTH_PAY : '条形码支付',
      WAP_PAY : '网站支付',
      SUCCESS: '成功',
      WAITING_PAYMENT : '等待付款',
      CANCEL_TRANSFER: '取消转帐',
      TRADE_ORDER: '支付',
      WITHDRAWAL: '转出',
      DEPOSIT: '转入',
      WITHDRAWAL_CASH: '提现',
      PENDING: '待审核',
      APPROVAL: '待转账',
      COMPLETED: '完成',
      FAILED: '失败',
      REJECTED: '拒绝',
      CANCELED: '取消'
    } ;
    if (map[value]){
      text = map[value];
    }

    return text;
  }
}


/**
 * 交易狀態集（下拉框）
 *
 */
export const TradeTypes: TradeType[] = [
  {
      value: 'SUCCESS',
      name: '医保',
  },
  {
      value: 'WAITING_PAYMENT',
      name: '自费',
  }
];
/**
 * 科室
 *
 */
export const ksData: any[] =[
    {
      title: '外科',
      value: '0-0',
      key: '外科',
      children: [
        {
            title: '胃肠外科',
            value: '0-0-1',
            key: '胃肠外科',
            isLeaf: true
        },{
            title: '神经外科',
            value: '0-0-2',
            key: '神经外科',
            isLeaf: true
        },{
            title: '创伤骨外科',
            value: '0-0-4',
            key: '创伤骨外科',
            isLeaf: true
        },{
            title: '耳鼻咽喉科',
            value: '0-0-5',
            key: '耳鼻咽喉科',
            isLeaf: true
        },{
            title: '肝胆外科',
            value: '0-0-7',
            key: '肝胆外科',
            isLeaf: true
        },{
            title: '胸外科',
            value: '0-0-8',
            key: '胸外科',
            isLeaf: true
        },{
            title: '关节外科',
            value: '0-0-9',
            key: '关节外科',
            isLeaf: true
        },{
            title: '脊柱外科',
            value: '0-0-10',
            key: '脊柱外科',
            isLeaf: true
        },{
            title: '肛肠科',
            value: '0-0-11',
            key: '肛肠科',
            isLeaf: true
        },{
            title: '乳腺外科',
            value: '0-0-12',
            key: '乳腺外科',
            isLeaf: true

        }
      ]
    },
    {
      title: '内科',
      value: '0-1',
      key: '内科',
      children: [
          {
              title: '神经内科',
              value: '0-1-0',
              key: '神经内科',
              isLeaf: true
            },
            {
                title: '呼吸内科',
                value: '0-1-1',
                key: '呼吸内科',
                isLeaf: true
            },{
                title: '消化内科',
                value: '0-1-2',
                key: '消化内科',
                isLeaf: true
            },{
                title: '血液内科',
                value: '0-1-3',
                key: '血液内科',
                isLeaf: true
            },{
                title: '内分泌内科',
                value: '0-1-4',
                key: '内分泌内科',
                isLeaf: true
            },{
                title: '风湿免疫科',
                value: '0-1-5',
                key: '风湿免疫科',
                isLeaf: true
            },{
                title: '肾内科',
                value: '0-1-6',
                key: '肾内科',
                isLeaf: true
            },{
                title: '血液净化中心感染性疾病科',
                value: '0-1-7',
                key: '血液净化中心感染性疾病科',
                isLeaf: true
            },{
                title: '肝病科',
                value: '0-1-8',
                key: '肝病科',
                isLeaf: true
            },{
                title: '中医科',
                value: '0-1-9',
                key: '中医科',
                isLeaf: true
            },{
                title: '介入科',
                value: '0-1-10',
                key: '介入科',
                isLeaf: true
            },{
                title: '康复医学科',
                value: '0-1-11',
                key: '康复医学科',
                isLeaf: true
            },{
                title: '皮肤科',
                value: '0-1-12',
                key: '皮肤科',
                isLeaf: true
            }
      ]
    },{
        title: '心血管中心',
        value: '0-3',
        key: '心血管中心',
        children: [
            {
                title: '心血管内科',
                value: '0-3-0',
                key: '心血管内科',
                isLeaf: true
              },
              {
                  title: '心脏大血管外科',
                  value: '0-3-1',
                  key: '心脏大血管外科',
                  isLeaf: true
              }
            ]
    },{
        title: '肿瘤防治中心',
        value: '0-4',
        key: '肿瘤防治中心',
        children: [
            {
                title: '化疗科',
                value: '0-4-0',
                key: '化疗科',
                isLeaf: true
              },
              {
                  title: '放疗科',
                  value: '0-4-1',
                  key: '放疗科',
                  isLeaf: true
              }
            ]
    },{
        title: '妇儿中心',
        value: '0-5',
        key: '妇儿中心',
        children: [
            {
                title: '生殖医学科',
                value: '0-5-0',
                key: '生殖医学科',
                isLeaf: true
              },{
                  title: '产科',
                  value: '0-5-1',
                  key: '产科',
                  isLeaf: true
              },{
                  title: '小儿外科',
                  value: '0-5-2',
                  key: '小儿外科',
                  isLeaf: true
              },{
                  title: '儿内科',
                  value: '0-5-3',
                  key: '儿内科',
                  isLeaf: true
              },{
                  title: '妇科',
                  value: '0-5-4',
                  key: '妇科',
                  isLeaf: true
              }
            ]
    },{
        title: '泌尿外科中心',
        value: '0-6',
        key: '泌尿外科中心',
        children: [
            {
                title: '泌尿外科',
                value: '0-6-0',
                key: '泌尿外科',
                isLeaf: true
              }
            ]
    },{
        title: '门急诊、麻醉',
        value: '0-7',
        key: '门急诊、麻醉',
        children: [
            {
                title: '本部门诊',
                value: '0-7-0',
                key: '本部门诊',
                isLeaf: true
              },{
                title: '医学科院',
                value: '0-7-1',
                key: '医学科院',
                isLeaf: true
              },{
                title: '急诊',
                value: '0-7-2',
                key: '急诊',
                isLeaf: true
              },{
                title: 'ICU急诊综合病区',
                value: '0-7-3',
                key: 'ICU急诊综合病区',
                isLeaf: true
              },{
                title: '麻醉科急诊',
                value: '0-7-4',
                key: '麻醉科急诊',
                isLeaf: true
              }
            ]
        }

  ];
  export interface TradeType {
  value: string;
  name: string;
  translate?: string;
}


/**
 * 日期格式化
 */
export const formatDateGlob = ( time: any ) => {
  // 格式化日期，获取今天的日期
    if (time) {
        const Dates = new Date( time );
        const year: number = Dates.getFullYear();
        const month: any = ( Dates.getMonth() + 1 ) < 10 ? '0' + ( Dates.getMonth() + 1 ) : ( Dates.getMonth() + 1 );
        const day: any = Dates.getDate() < 10 ? '0' + Dates.getDate() : Dates.getDate();
        return year + '-' + month + '-' + day;
    } else {
        return;
    }
};
